<template>
	<view class="code">
		<view class="code-title">
			输入6位验证码
		</view>
		<view class="code-desc">
			验证码已发送至150 1979 7927 <text>54s后重发</text>
		</view>
		<view class="code-wrap">
			<up-code-input focus bold v-model="value" maxlength="6" :space="10" @finish="finish"></up-code-input>
		</view>
	</view>
</template>

<script setup>
import {ref} from 'vue'
import {codeLogin} from '../../api/login.js'
import store from '@/store/index.js'
const value = ref()
const finish = async (e) => {  
  console.log('输入结束，当前值为：' + e);
  let res = await codeLogin({
	  mobile: '',
	  captcha: e
  })
  if (res.data.accessToken) {
	  store.commit('setToken',res.data.accessToken)
	  uni.switchTab({
	  	url: '/pages/tabs/mine'
	  })
  }
}

</script>

<style lang="scss">
.code{
	padding: 50rpx;
	.code-title{
		font-size: 35rpx;
		font-weight: 700;
	}
	.code-desc{
		margin-top: 30rpx;
		font-size: 25rpx;
		color: #a2a2a2;
		>text{
			margin-left: 80rpx;
		}
	}
	.code-wrap{
		margin-top: 80rpx;
		display: flex;
		justify-content: space-between;
	}
}
</style>